package com.huaxonline.boot.web.util;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;

/**
 * 生成AppId和Secret的工具类
 *
 * @author zhaoshulei
 */
public class AppUtil {

    public static String createAppId() {
        return IdUtil.simpleUUID();
    }

    public static String createAppId(String appName) {
        if (StrUtil.isBlank(appName)) {
            return IdUtil.simpleUUID();
        }
        return SecureUtil.md5(appName);
    }

    public static String createSecret(String appId) {
        return SecureUtil.sha256(appId);
    }

    public static void main(String[] args) {
        String appId = createAppId();
        String secret = createSecret(appId);
        System.out.println("AppId=" + appId);
        System.out.println("Secret=" + secret);
    }
}
